package interpreter.debugger.ui;

/**
 *
 * @author Kris Selbekk
 */
public class DisplayFuncSrcCommand extends Command {
    public void exec( String[] args ) {
    }

    public void print() {
        StringBuilder out = new StringBuilder();

        // If no function is yet active, give warning
        if( dvm.getFunctionName() == null ) {
            out.append("No function entered yet.");
        } else {

            out.append("Function: ");
            out.append(dvm.getFunctionName());
            out.append("\n--------------------\n");

            for( int i = dvm.getStartLine(); i <= dvm.getEndLine(); i++) {
                 System.out.print( String.format("%3d. %s", i, dvm.getSource(i) ));
                 if( i == dvm.getCurrentLine())
                     System.out.print("\t\t<---");
                 System.out.println();
            }
        }
        System.out.println(out);
    }
}
